package top.api.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum CommonPayTypeEnum {
    // QQ: 0 微信: 1 支付宝: 2 余额: 3
    qq(0,"QQ"),
    wx(1,"微信"),
    alipay(2,"支付宝"),
    money(3,"余额"),
    LINK(4,"链接");

    @EnumValue
    @JsonValue
    private final int code;

    private final String type;

    CommonPayTypeEnum(int code, String type) {
        this.code = code;
        this.type = type;
    }

    public int getCode() {
        return code;
    }

    public String getType() {
        return type;
    }

    public static CommonPayTypeEnum getCommonPayTypeEnumByCode(int code) {
        for (CommonPayTypeEnum payTypeEnum : CommonPayTypeEnum.values()) {
            if (payTypeEnum.getCode() == code) {
                return payTypeEnum;
            }
        }
        throw new RuntimeException("没有满足条件的枚举");
    }
}
